package com.iteaj.iot.test.server.fixed;

import com.iteaj.iot.redis.handle.RedisListHandle;
import com.iteaj.iot.server.ServerProtocolHandle;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 固定长度+redis测试
 */
@Component
public class FixedLengthClientRequestHandle implements ServerProtocolHandle<FixedLengthClientRequestProtocol>, RedisListHandle<FixedLengthClientRequestProtocol, Object> {

    // 从redis消费数据
    @Override
    public Integer consumer(List<Object> objects) {
        return objects.size();
    }

    // 此方法直接写业务
    @Override
    public Object handle(FixedLengthClientRequestProtocol protocol) {
        return new Object(); // 返回的对象将直接存入redis
    }

    /**
     * 数据将写入到此Key的list里面
     * @return
     */
    @Override
    public String getKey() {
        return "Fixed_Redis_Key";
    }
}
